<?php
  include_once("../sql_connect.php");
  include_once("../msg_redirect.php");
?>
<?php
/*修改用户密码模块*/

$u_no = $_COOKIE['u_no'];
$original_passwd = md5($_POST[original_passwd]);
$new_passwd = md5($_POST[new_passwd]);
$new_passwd_confirmed = md5($_POST[new_passwd_confirmed]);

if ($new_passwd == $new_passwd_confirmed){	/*如果两次输入的新密码一样，则再检测输入的原始密码与数据库中得是否一样*/
	$my_sql = mysql_query("select u_passwd from user_info where u_no='$u_no'",$connection);
	$my_result = mysql_fetch_array($my_sql);
	$passwd = $my_result[u_passwd];
	
	if ($passwd == $original_passwd){	/*如果原始密码匹配*/
		$my_sql1 = mysql_query("update user_info set u_passwd='$new_passwd' where u_no='$u_no'");
		
		if ($my_sql1){	/*查看操作数据库是否成功*/
			echo "密码修改成功！";
		}
		else echo "密码修改失败，请稍后再试！";
	}
	else "原密码输入错误！";
}

?>
